package com.imarkket.sqlite.model;

import android.text.format.DateFormat;

import com.imarkket.Library.c_crypter;
import com.imarkket.Library.c_logging;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

/**
 * Created by Sistemas on 04/06/2014.
 */
public class t_lista {

    int NCOD_INTERNO;

    String ADES_LARGA;
    String ADES_HASH;

    int NCOD_SHARED;

    // Indica cuantos elementos hay en una lista.
    int NCOD_COUNT;
    int NCOD_RATING;

    CharSequence DFEC_CREACION;
    CharSequence DFEC_UPDATED;

    // constructors
    public t_lista () {

    }

    public t_lista(String pADES_LARGA, int pNCOD_SHARED, int pNCOD_COUNT, int pNCOD_RATING) {
        // Desactivado al ser AUTO INCREMENT
        // this.NCOD_INTERNO = pNCOD_INTERNO;

        // Inicializamos la ApiCripter
        c_crypter AC = new c_crypter();
        this.ADES_HASH = AC.md5(pADES_LARGA);

        this.ADES_LARGA = pADES_LARGA;
        this.NCOD_COUNT = pNCOD_COUNT;

        //Getting Current Time
        Calendar ctaq = Calendar.getInstance();
        SimpleDateFormat dfaq = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        //Getting Current Timezone
        Calendar cll = Calendar.getInstance();
        TimeZone z = cll.getTimeZone();
        c_logging.getInstance().log(c_logging.LOG_INFO, "Time: "+dfaq.format(ctaq.getTime()) + " - Time zone: "+z.getDisplayName());

        this.DFEC_CREACION = dfaq.format(ctaq.getTime());
        this.DFEC_UPDATED =  dfaq.format(ctaq.getTime());

        this.NCOD_SHARED = pNCOD_SHARED;
        this.NCOD_RATING = pNCOD_RATING;

        c_logging.getInstance().log(c_logging.LOG_INFO, "LIST: " + this.NCOD_INTERNO + " - "

                                                                 + this.ADES_LARGA + " - "
                                                                 + this.ADES_HASH + " - "

                                                                 + this.NCOD_SHARED + " - "
                                                                 + this.NCOD_COUNT + " - "
                                                                 + this.NCOD_RATING  + " - "

                                                                 + this.DFEC_CREACION.toString() + " - "
                                                                 + this.DFEC_UPDATED.toString() );
    }

    // setters
    public void setNCOD_INTERNO(int pNCOD_INTERNO) {
        this.NCOD_INTERNO = pNCOD_INTERNO;
    }

    public void setADES_LARGA(String pADES_LARGA) {
        this.ADES_LARGA = pADES_LARGA;
    }

    public void setADES_HASH(String pADES_HASH) {
        this.ADES_HASH = pADES_HASH;
    }

    public void setDFEC_CREACION(CharSequence pDFEC_CREACION) {
        this.DFEC_CREACION = pDFEC_CREACION;
    }

    public void setDFEC_UPDATE(CharSequence pDFEC_UPDATE) {
        this.DFEC_UPDATED = pDFEC_UPDATE;
    }

    public void setNCOD_SHARED(int pNCOD_SHARED) {
        this.NCOD_SHARED = pNCOD_SHARED;
    }

    public void setNCOD_COUNT(int pNCOD_COUNT) {
        this.NCOD_COUNT = pNCOD_COUNT;
    }

    public void setNCOD_RATING ( int pNCOD_RATING ) {
        this.NCOD_RATING = pNCOD_RATING;
    }


    // getters
    public int getNCOD_INTERNO() {
        return this.NCOD_INTERNO;
    }

    public String getADES_LARGA() {
        return this.ADES_LARGA;
    }

    public String getADES_HASH() {
        return this.ADES_HASH;
    }

    public CharSequence getDFEC_CREACION() {
        return this.DFEC_CREACION;
    }

    public CharSequence getDFEC_UPDATE() { return this.DFEC_UPDATED; }

    public int getNCOD_SHARED() {  return this.NCOD_SHARED; }

    public long getNCOD_COUNT() { return this.NCOD_COUNT; }

    public long getNCOD_RATING() { return this.NCOD_RATING; }
}
